package com.cskaoyan.controller.admin;


import com.cskaoyan.bean.bo.OrderSearchBo;
import com.cskaoyan.bean.entity.Comment;
import com.cskaoyan.bean.entity.Channel;
import com.cskaoyan.bean.entity.Order;
import com.cskaoyan.bean.vo.BasePageData;
import com.cskaoyan.bean.vo.BaseParam;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.OrderDetailVo;
import com.cskaoyan.common.aop.OperateLog;
import com.cskaoyan.service.OrderService;
import com.cskaoyan.utils.BaseRespVoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("admin/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    /**
     *  根据参数查询获取订单
     *
     */
    @RequestMapping("list")
    public BaseRespVo list(BaseParam baseParam, OrderSearchBo orderSearchBo){
        BasePageData<Order>  orderBasePageData = orderService.query(baseParam,orderSearchBo);
        return BaseRespVo.ok(orderBasePageData);
    }

    /**
     *  获取所有的快递公司
     *
     */
    @RequestMapping("channel")
    public BaseRespVo getChannel(){
        List<Channel> channelList = orderService.getChannel();
        return BaseRespVo.ok(channelList);
    }

    /**
     *  订单详情
     *
     */
    @RequestMapping("detail")
    public BaseRespVo detail(Integer id){
        OrderDetailVo orderDetailVo = orderService.detail(id);
        return BaseRespVo.ok(orderDetailVo);
    }

    /**
     *  删除订单
     *
     */
    @OperateLog(opType = "订单操作",opAction = "删除")
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody Integer id) {
        orderService.delete(id);
        return BaseRespVo.ok();

    }

    //    http://localhost:8083/admin/order/reply
    //    回复商品评论
    @RequestMapping("reply")
    public BaseRespVo reply(@RequestBody Comment comment){
        int addreply = orderService.addreply(comment);
        return BaseRespVo.ok(addreply);

    }
}
